<template>
  <div class="login_wrapper">
    <div class="login login-box">
      <img src="../../assets/img/o_login.png" alt="" srcset="" />
      <h2>财乎主播直播工具WEB版本</h2>
      <el-form
        :model="params"
        ref="form"
        :rules="rules"
        label-width="80px"
        :inline="false"
        size="large"
        :label-position="'top'"
      >
        <el-form-item label="手机号：">
          <el-input v-model="params.mobile" style="width: 350px"></el-input>
        </el-form-item>
        <el-form-item label="密码：">
          <el-input v-model="params.password" type="password"></el-input>
        </el-form-item>
        <el-form-item>
          <!-- <el-button type="primary" style="width: 100%" @click="onSubmit"
            >登录</el-button
          > -->
          <button href="#" style="width: 100%" @click="onSubmit">
            <span></span>
            <span></span>
            <span></span>
            <span></span>
            登 录
          </button>
        </el-form-item>
        <p class="tips">提示：为了更好体验请使用谷歌浏览器访问</p>
      </el-form>
    </div>
  </div>
</template>

<script>
import {
  defineComponent,
  ref,
  reactive,
  nextTick,
  onMounted,
  toRaw,
  toRefs,
  watch,
} from "vue";
import { useRouter } from "vue-router";
import { login } from "../../api/teacher";
import { encruption } from "../../utils";
import storage from "../../utils/storage";
export default defineComponent({
  setup() {
    const params = reactive({
      mobile: "13160699710",
      password: "123456789",
    });
    const rules = ref({});
    const router = useRouter();
    const onSubmit = async () => {
      const data = { ...params };
      data.account = data.mobile;
      data.password = encruption(data.password);
      const res = await login(data);
      console.log(res);
      if (res && typeof res == "object") {
        storage.setStorage("teacher_user", res.user);
        storage.setStorage("teacher_token", res.token);
        router.push("/liveSet");
      }
    };
    return {
      rules,
      params,
      onSubmit,
    };
  },
});
</script>



<style scoped lang='scss'>
.login_wrapper {
  width: 100%;
  position: absolute;
  height: 100%;
  background: url("../../assets/img/bg2.webp");
  overflow: hidden;
  .login {
    width: 450px;
    overflow: hidden;
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #fff;
    padding: 25px;
    border-radius: 10px;
    background: rgba(0, 17, 53, 0.616);
    box-shadow: 0 10px 10px rgba(0, 0, 0, 0.671);
    img {
      width: 80px;
      height: 80px;
      margin-bottom: 20px;
    }
    h2 {
      font-weight: bold;
      font-size: 28px;
      margin-top: 10px;
      margin-bottom: 20px;
      color: #f7c626;
    }
    .tips {
      color: #e7e5e5;
    }
  }
}

.login-box button {
  position: relative;
  display: inline-block;
  padding: 10px 20px;
  color: #03e9f4;
  font-size: 16px;
  text-decoration: none;
  text-transform: uppercase;
  overflow: hidden;
  transition: 0.5s;
  margin-top: 40px;
  letter-spacing: 4px;
  border: none;
  background: #0e83e2;
  cursor: pointer;
  border-radius: 5px;
  color: #fff;
}

.login-box button:hover {
  background: #0363f4;
  color: #fff;
  border-radius: 5px;
  box-shadow: 0 0 5px #03a8f4, 0 0 25px #03a8f4, 0 0 50px #03a8f4,
    0 0 100px #03a8f4;
}

.login-box button span {
  position: absolute;
  display: block;
}

.login-box button span:nth-child(1) {
  top: 0;
  left: -100%;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #03e9f4);
  animation: btn-anim1 1.5s linear infinite;
}

@keyframes btn-anim1 {
  0% {
    left: -100%;
  }
  50%,
  100% {
    left: 100%;
  }
}

.login-box button span:nth-child(2) {
  top: -100%;
  right: 0;
  width: 2px;
  height: 100%;
  background: linear-gradient(180deg, transparent, #03e9f4);
  animation: btn-anim2 1s linear infinite;
  animation-delay: 0.75s;
}

@keyframes btn-anim2 {
  0% {
    top: -100%;
  }
  50%,
  100% {
    top: 100%;
  }
}

.login-box button span:nth-child(3) {
  bottom: 0;
  right: -100%;
  width: 100%;
  height: 2px;
  background: linear-gradient(270deg, transparent, #03e9f4);
  animation: btn-anim3 1s linear infinite;
  animation-delay: 1s;
}

@keyframes btn-anim3 {
  0% {
    right: -100%;
  }
  50%,
  100% {
    right: 100%;
  }
}

.login-box button span:nth-child(4) {
  bottom: -100%;
  left: 0;
  width: 2px;
  height: 100%;
  background: linear-gradient(360deg, transparent, #03e9f4);
  animation: btn-anim4 1s linear infinite;
  animation-delay: 1.25s;
}

@keyframes btn-anim4 {
  0% {
    bottom: -100%;
  }
  50%,
  100% {
    bottom: 100%;
  }
}
</style>